package com.teamcenter.rac.massupdate.ui.grid;

import net.sourceforge.nattable.data.IColumnPropertyAccessor;

public class ColumnAccessor<T extends IGridRow>
  implements IColumnPropertyAccessor<T>
{
  private final GridColumn[] m_columns;
  
  public ColumnAccessor(GridColumn[] paramArrayOfGridColumn)
  {
    this.m_columns = paramArrayOfGridColumn;
  }
  
  public Object getDataValue(IGridRow paramIGridRow, int paramInt)
  {
    return paramIGridRow.getValue(getColumnProperty(this.m_columns[paramInt].getIndex()));
  }
  
  public int getColumnCount()
  {
    return this.m_columns.length;
  }
  
  public int getColumnIndex(String paramString)
  {
    for (int i = 0; i < this.m_columns.length; i++) {
      if (this.m_columns[i].getName().equals(paramString)) {
        return i;
      }
    }
    return -1;
  }
  
  public String getColumnProperty(int paramInt)
  {
    return this.m_columns[paramInt].getName();
  }
  
  public void setDataValue(IGridRow paramIGridRow, int paramInt, Object paramObject)
  {
    if (this.m_columns[paramInt].isEditable()) {
      paramIGridRow.setValue(getColumnProperty(paramInt), paramObject);
    }
  }
}

